home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / user / flipschedule.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  4KB  |  181 lines

  1. /* Mode=Run */
  2. /* ***********************************************************************
  3.  
  4.    FLIPSCHEDULE PROGRAM FOR FOOTBALL REXX SUITE
  5.   ----------------------------------------------
  6.                    Copyright  Mark Naughton 1996
  7.  
  8.  
  9. Version    Date     History
  10. --------------------------------------------------------------------------
  11.  1.0       270996   First release.
  12.  1.1       121196   Added to Football as a callable component. Amended for
  13.                     different leagues. Removed messages.
  14.            131196   Added checks for files - if not found, exits without
  15.                     a message.
  16.            241196   Now called as an External script. Added info messages.
  17.  1.2       050599   Updated to only allow non-scheduled leagues to be
  18.                     flipped and printed.
  19.            250899   Added error msg to file checks.
  20.            280899   Converted to use locale. Some error messages, before
  21.                     reading the locale, will still be in English.
  22.  
  23. **************************************************************************
  24.  
  25. Procedure
  26. ---------
  27.  
  28. 1. Check files exist. Read '.df' file for schedule info.
  29. 2. If scheduled, exit with message. Open Learn file and output file.
  30. 3. Read from Learn, then flip the home and away teams, reset the scores
  31.    to 'not_played' and then write to output file.
  32. 4. Close files and end. When finished this file can then be printed off
  33.    and it'll make entering data into GAMEPLAY much easier.
  34.  
  35. ************************************************************************** */
  36. parse arg league_file
  37.  
  38. league_file  = "Data/" || league_file
  39. version      = 1
  40. input_file   = '.sflearn'
  41. input2_file  = '.df'
  42. output_file  = '.sflisting'
  43. not_played   = '__   __'
  44. separator    = '*'
  45. autosched    = "*AUTOSCHD="
  46. autos        = 0
  47.  
  48.  
  49. if open(datafile,"Data/Football.locale",'r') then do
  50.    line = readln(datafile)
  51.    locdir = strip(line)
  52.    close(datafile)
  53. end
  54. else do
  55.    say
  56.    say "ERROR :    (FlipSchedule)"
  57.    say
  58.    say "Cannot read 'Data/Football.locale' for the locale settings."
  59.    exit
  60. end
  61.  
  62. locdir = locdir"User/FlipSchedule.data"
  63.  
  64. if open(datafile,"ENV:FootballRXPath",'r') then do
  65.    line = readln(datafile)
  66.    rxdir = strip(line)
  67.    close(datafile)
  68. end
  69. else
  70.    rxdir = "SYS:Rexxc/"
  71.  
  72. if exists(locdir) > 0 then do
  73.   address command rxdir'rx 'locdir
  74.   VarCount = getclip('VarCount')
  75.   do i = 1 to VarCount
  76.     interpret getclip('var.'i)
  77.   end
  78. end
  79. else do
  80.    say
  81.    say "ERROR :    (FlipSchedule)"
  82.    say
  83.    say "Cannot find '"locdir"' to read locale settings."
  84.    exit
  85. end
  86.  
  87. if exists(league_file || input_file) = 0 then do
  88.    say
  89.    say fs_error
  90.    say
  91.    say fs_one"'"league_file || input_file"'."
  92.    exit
  93. end
  94.  
  95. if exists(league_file || input2_file) = 0 then do
  96.    say
  97.    say fs_error
  98.    say
  99.    say fs_one"'"league_file || input2_file"'."
  100.    exit
  101. end
  102.  
  103. if open(datafile2,league_file || input2_file,'r') then do
  104.    do while ~eof(datafile2)
  105.       line = readln(datafile2)
  106.       if pos(autosched,line) > 0 then
  107.          autos = 1
  108.    end
  109.    close(datafile2)
  110. end
  111. else do
  112.    say
  113.    say fs_error
  114.    say
  115.    say fs_two"'"league_file || input2_file"'."
  116.    exit
  117. end
  118.  
  119. if autos = 1 then do
  120.    say
  121.    say fs_error
  122.    say
  123.    say fs_three
  124.    say fs_four
  125.    say fs_txt1
  126.    say
  127.    exit
  128. end
  129.  
  130. say
  131. say center(fs_txt2,78)
  132. say "--------------------------------------------------------------------------"
  133. say
  134. say fs_txt3
  135. say fs_txt4
  136. say fs_txt5
  137. say fs_txt6
  138. say fs_txt7"'"league_file || output_file"'"
  139. say fs_txt8
  140. say
  141. say fs_txt9
  142. say
  143.  
  144. if open(datafile,league_file || input_file,'r') then do
  145.    if open(datafile2,league_file || output_file,'w') then do
  146.       do while ~eof(datafile)
  147.          line = readln(datafile)
  148.          if pos(separator,line) = 0 then do
  149.             home = substr(line,1,30)
  150.             away = substr(line,41,30)
  151.             line = overlay(away,line,1)
  152.             line = overlay(home,line,41)
  153.             if pos(not_played,line) = 0  & words(line) > 0 then
  154.                line = overlay(not_played,line,32)
  155.          end
  156.          writeln(datafile2,line)
  157.       end
  158.       close(datafile2)
  159.       say fs_txt0
  160.       say fs_txta"'"league_file || output_file"'"fs_txtb
  161.       say
  162.       say
  163.    end
  164.    else do
  165.       say
  166.       say fs_error
  167.       say
  168.       say fs_txtc"'"league_file || output_file"'"fs_txtd
  169.       close(datafile)
  170.       exit
  171.    end
  172.    close(datafile)
  173. end
  174. else do
  175.    say
  176.    say fs_error
  177.    say
  178.    say fs_txtc"'"league_file || input_file"'"fx_txte
  179. end
  180.  
  181. exit